/*
 *Copyright (c) 2024 Black Sesame Technologies
 *
 *Licensed under the Apache License, Version 2.0 (the "License");
 *you may not use this file except in compliance with the License.
 *You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 *Unless required by applicable law or agreed to in writing, software
 *distributed under the License is distributed on an "AS IS" BASIS,
 *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *See the License for the specific language governing permissions and
 *limitations under the License.
*/


#ifndef _INTNUM_H
#define _INTNUM_H

#include "../modules/gic/gic_basic.h"

#define IRQ_ENABLE  cpu_gicd_set_enable
#define IRQ_DISABLE cpu_gicd_clear_enable


typedef enum{
    GIC_SGI_INT_0,
    GIC_SGI_INT_1,
    GIC_SGI_INT_2,
    GIC_SGI_INT_3,
    GIC_SGI_INT_4,
    GIC_SGI_INT_5,
    GIC_SGI_INT_6,
    GIC_SGI_INT_7,
    GIC_SGI_INT_8,
    GIC_SGI_INT_9,
    GIC_SGI_INT_10,
    GIC_SGI_INT_11,
    GIC_SGI_INT_12,
    GIC_SGI_INT_13,
    GIC_SGI_INT_14,
    GIC_SGI_INT_15,
    SW_INTR_R5_0_CTI_INT0                                                  = 32,
    SW_INTR_R5_0_CTI_INT1                                                  ,
    SW_INTR_R5_1_CTI_INT0                                                  ,
    SW_INTR_R5_1_CTI_INT1                                                  ,
    SW_INTR_R5_2_CTI_INT0                                                  ,
    SW_INTR_R5_2_CTI_INT1                                                  ,
    SW_INTR_R5_0_APB_TX_INT0                                               ,
    SW_INTR_R5_0_APB_TX_INT1                                               ,
    SW_INTR_R5_0_APB_TX_INT2                                               ,
    SW_INTR_R5_0_APB_TX_INT3                                               ,
    SW_INTR_R5_1_APB_TX_INT0                                               ,
    SW_INTR_R5_1_APB_TX_INT1                                               ,
    SW_INTR_R5_1_APB_TX_INT2                                               ,
    SW_INTR_R5_1_APB_TX_INT3                                               ,
    SW_INTR_R5_2_APB_TX_INT0                                               ,
    SW_INTR_R5_2_APB_TX_INT1                                               ,
    SW_INTR_R5_2_APB_TX_INT2                                               ,
    SW_INTR_R5_2_APB_TX_INT3                                               ,
    SW_INTR_GMAC_INTR                                                      ,
    SW_INTR_GMAC_PERCH_RX_INTR0                                            ,
    SW_INTR_GMAC_PERCH_RX_INTR1                                            ,
    SW_INTR_GMAC_PERCH_RX_INTR2                                            ,
    SW_INTR_GMAC_PERCH_RX_INTR3                                            ,
    SW_INTR_GMAC_PERCH_TX_INTR0                                            ,
    SW_INTR_GMAC_PERCH_TX_INTR1                                            ,
    SW_INTR_GMAC_PERCH_TX_INTR2                                            ,
    SW_INTR_GMAC_PERCH_TX_INTR3                                            ,
    SW_INTR_PCS_INTR0                                                      ,
    SW_INTR_PCS_INTR1                                                      ,
    SW_INTR_PCS_INTR2                                                      ,
    SW_INTR_PCS_INTR3                                                      ,
    SW_INTR_NPU_INTR0                                                      ,
    SW_INTR_NPU_INTR1                                                      ,
    SW_INTR_NPU_INTR2                                                      ,
    SW_INTR_NPU_INTR3                                                      ,
    SW_INTR_NPU_INTR4                                                      ,
    SW_INTR_NPU_INTR5                                                      ,
    SW_INTR_NPU_INTR6                                                      ,
    SW_INTR_NPU_INTR7                                                      ,
    SW_INTR_NPU_INTR8                                                      ,
    SW_INTR_NPU_INTR9                                                      ,
    SW_INTR_NPU_INTR10                                                     ,
    SW_INTR_NPU_INTR11                                                     ,
    SW_INTR_NPU_INTR12                                                     ,
    SW_INTR_NPU_INTR13                                                     ,
    SW_INTR_NPU_INTR14                                                     ,
    SW_INTR_NPU_INTR15                                                     ,
    SW_INTR_NPU_INTR16                                                     ,
    SW_INTR_NPU_INTR17                                                     ,
    SW_INTR_EPP_XGMAC_SBD_INTR_COMBAND                                     ,
    SW_INTR_FLEXRAY_INTR0                                                  ,
    SW_INTR_FLEXRAY_INTR1                                                  ,
    SW_INTR_LIN_INTR0                                                      ,
    SW_INTR_LIN_INTR1                                                      ,
    SW_INTR_LIN_INTR2                                                      ,
    SW_INTR_LIN_INTR3                                                      ,
    SW_INTR_LIN_INTR4                                                      ,
    SW_INTR_LIN_INTR5                                                      ,
    SW_INTR_CAN_INTR0                                                      ,
    SW_INTR_CAN_INTR1                                                      ,
    SW_INTR_CAN_INTR2                                                      ,
    SW_INTR_CAN_INTR3                                                      ,
    SW_INTR_CAN_INTR4                                                      ,
    SW_INTR_CAN_INTR5                                                      ,
    SW_INTR_CAN_INTR6                                                      ,
    SW_INTR_CAN_INTR7                                                      ,
    SW_INTR_CAN_INTR8                                                      ,
    SW_INTR_CAN_INTR9                                                      ,
    SW_INTR_CAN_INTR10                                                     ,
    SW_INTR_CAN_INTR11                                                     ,
    SW_INTR_CAN_INTR12                                                     ,
    SW_INTR_CAN_INTR13                                                     ,
    SW_INTR_CAN_INTR14                                                     ,
    SW_INTR_CAN_INTR15                                                     ,
    SW_INTR_TIMER_INTR0                                                    ,
    SW_INTR_TIMER_INTR1                                                    ,
    SW_INTR_TIMER_INTR2                                                    ,
    SW_INTR_TIMER_INTR3                                                    ,
    SW_INTR_TIMER_INTR4                                                    ,
    SW_INTR_TIMER_INTR5                                                    ,
    SW_INTR_TIMER_INTR6                                                    ,
    SW_INTR_TIMER_INTR7                                                    ,
    SW_INTR_WDT_INTR0                                                      ,
    SW_INTR_WDT_INTR1                                                      ,
    SW_INTR_WDT_INTR2                                                      ,
    SW_INTR_WDT_INTR3                                                      ,
    SW_INTR_WDT_INTR4                                                      ,
    SW_INTR_WDT_INTR5                                                      ,
    SW_INTR_MSGBOX_INTR0                                                   ,
    SW_INTR_MSGBOX_INTR1                                                   ,
    SW_INTR_MSGBOX_INTR2                                                   ,
    SW_INTR_MSGBOX_INTR3                                                   ,
    SW_INTR_MSGBOX_INTR4                                                   ,
    SW_INTR_MSGBOX_INTR5                                                   ,
    SW_INTR_MSGBOX_INTR6                                                   ,
    SW_INTR_MSGBOX_INTR7                                                   ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR0                                          ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR1                                          ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR2                                          ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR3                                          ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR4                                          ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR5                                          ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR6                                          ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR7                                          ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR8                                          ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR9                                          ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR10                                         ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR11                                         ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR12                                         ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR13                                         ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR14                                         ,
    SW_INTR_SIMPLE_DMA_FUNC_INTR15                                         ,
    SW_INTR_SEC_INTR0                                                      ,
    SW_INTR_SEC_INTR1                                                      ,
    SW_INTR_SEC_INTR2                                                      ,
    SW_INTR_SEIP_HASH_BUSERR_INTR                                          ,
    SW_INTR_SEIP_SKE_BUSERR_INTR                                           ,
    SW_INTR_DMA_INTR0                                                      ,
    SW_INTR_DMA_INTR1                                                      ,
    SW_INTR_DMA_INTR2                                                      ,
    SW_INTR_DMA_INTR3                                                      ,
    SW_INTR_DMA_CMNREG_INTR                                                ,
    SW_INTR_SW_IPC_BANK0                                                   ,
    SW_INTR_SW_IPC_BANK1                                                   ,
    SW_INTR_SW_IPC_EVENT0                                                  ,
    SW_INTR_PLL_INTR0                                                      ,
    SW_INTR_PLL_INTR1                                                      ,
    SW_INTR_CLOCK_MONITOR_ERROR0                                           ,
    SW_INTR_CLOCK_MONITOR_ERROR1                                           ,
    SW_INTR_SWITCH_SYS_CTR_CSR_ADDR_PTY_ERR                                ,
    SW_INTR_SWITCH_SYS_CTR_CSR_W_DATA_PTY_ERR                              ,
    SW_INTR_SWITCH_SYS_CRM_CSR_ADDR_PTY_ERROR                              , 
    SW_INTR_SWITCH_SYS_CRM_CSR_W_DATA_PTY_ERR                              , 
    SW_INTR_R5_0_SAFETY_INTERRUPT                                          , 
    SW_INTR_R5_1_SAFETY_INTERRUPT                                          , 
    SW_INTR_R5_2_SAFETY_INTERRUPT                                          , 
    SW_INTR_NOC_MAINMISSIONINT                                             , 
    SW_INTR_NOC_TIMEOUT_INTR                                               , 
    SW_INTR_NOC_R5_0_PARITY_INTR                                           , 
    SW_INTR_NOC_R5_1_PARITY_INTR                                           , 
    SW_INTR_NOC_R5_2_PARITY_INTR                                           , 
    SW_INTR_NOC_CRIT_PARITY_INTR                                           , 
    SW_INTR_NOC_PERI_PARITY_INTR                                           , 
    SW_INTR_NOC_RAM_PARITY_INTR                                            , 
    SW_INTR_EPP_NOC_CSFTY_INTR                                             , 
    SW_INTR_SRAM0_ECC_DECODE_ERR_INTR                                      , 
    SW_INTR_SRAM1_ECC_DECODE_ERR_INTR                                      , 
    SW_INTR_STANDBY_SRAM_ECC_DECODE_ERR_INTR                               , 
    SW_INTR_SRAM0_ECC_ENCODE_ERR_INTR                                      , 
    SW_INTR_SRAM1_ECC_ENCODE_ERR_INTR                                      , 
    SW_INTR_STANDBY_SRAM_ECC_ENCODE_ERR_INTR                               , 
    SW_INTR_SRAM0_ECC_ERROR_M_INTR                                         , 
    SW_INTR_SRAM1_ECC_ERROR_M_INTR                                         , 
    SW_INTR_STANDBY_SRAM_ECC_ERROR_M_INTR                                  , 
    SW_INTR_SRAM0_ECC_ERROR_S_INTR                                         , 
    SW_INTR_SRAM1_ECC_ERROR_S_INTR                                         , 
    SW_INTR_STANDBY_SRAM_ECC_ERROR_S_INTR                                  , 
    SW_INTR_MSGBOX_SFTY_INTR                                               , 
    SW_INTR_GMAC_SFTY_UE_INTR                                              , 
    SW_INTR_GMAC_SFTY_CE_INTR                                              , 
    SW_INTR_LSP_APB_PARITY_INTR                                            , 
    SW_INTR_CAN_ASILD_SAFETY_INTR0                                         , 
    SW_INTR_CAN_ASILD_SAFETY_INTR1                                         , 
    SW_INTR_CAN_ASILD_SAFETY_INTR2                                         , 
    SW_INTR_CAN_ASILD_SAFETY_INTR3                                         , 
    SW_INTR_CAN_ASILD_SAFETY_INTR4                                         , 
    SW_INTR_CAN_ASILD_SAFETY_INTR5                                         , 
    SW_INTR_CAN_ASILD_SAFETY_INTR6                                         , 
    SW_INTR_CAN_ASILD_SAFETY_INTR7                                         , 
    SW_INTR_CAN_ASILD_SAFETY_INTR8                                         , 
    SW_INTR_CAN_ASILD_SAFETY_INTR9                                         , 
    SW_INTR_CAN_ASILD_SAFETY_INTR10                                        , 
    SW_INTR_CAN_ASILD_SAFETY_INTR11                                        , 
    SW_INTR_CAN_ASILD_SAFETY_INTR12                                        , 
    SW_INTR_CAN_ASILD_SAFETY_INTR13                                        , 
    SW_INTR_CAN_ASILD_SAFETY_INTR14                                        , 
    SW_INTR_CAN_ASILD_SAFETY_INTR15                                        , 
    SW_INTR_CAN_SAFETY_INTR0                                               , 
    SW_INTR_CAN_SAFETY_INTR1                                               , 
    SW_INTR_CAN_SAFETY_INTR2                                               , 
    SW_INTR_CAN_SAFETY_INTR3                                               , 
    SW_INTR_CAN_SAFETY_INTR4                                               , 
    SW_INTR_CAN_SAFETY_INTR5                                               , 
    SW_INTR_CAN_SAFETY_INTR6                                               , 
    SW_INTR_CAN_SAFETY_INTR7                                               , 
    SW_INTR_CAN_SAFETY_INTR8                                               , 
    SW_INTR_CAN_SAFETY_INTR9                                               , 
    SW_INTR_CAN_SAFETY_INTR10                                              , 
    SW_INTR_CAN_SAFETY_INTR11                                              , 
    SW_INTR_CAN_SAFETY_INTR12                                              , 
    SW_INTR_CAN_SAFETY_INTR13                                              , 
    SW_INTR_CAN_SAFETY_INTR14                                              , 
    SW_INTR_CAN_SAFETY_INTR15                                              , 
    SW_INTR_SEC_TRNG_ALARM                                                 , 
    SW_INTR_SDMA0_SAFE_INTR                                                , 
    SW_INTR_EPP_XGMAC_SBD_SFTY_UE_INTR                                     , 
    SW_INTR_DMA_SAFE_INTR                                                  , 
    SW_INTR_EPP_SFTY_UE_INTR0                                              , 
    SW_INTR_EPP_SFTY_UE_INTR1                                              , 
    SW_INTR_EPP_SFTY_UE_INTR2                                              , 
    SW_INTR_EPP_SFTY_CE_INTR                                               , 
    SW_INTR_PCS_SFTY_UE_INTR0                                              , 
    SW_INTR_PCS_SFTY_UE_INTR1                                              , 
    SW_INTR_PCS_SFTY_UE_INTR2                                              , 
    SW_INTR_PCS_SFTY_UE_INTR3                                              , 
    SW_INTR_APB_BUS_PARITY_INTR                                            , 
    SW_INTR_EPP_XGMAC_SBD_SFTY_RE_INTR                                     , 
    SW_INTR_NPU_INTR18                                                     ,
    SW_INTR_SOC2SW_INTR0                                                   ,
    SW_INTR_SOC2SW_INTR1                                                   ,
    SW_INTR_SOC2SW_INTR2                                                   ,
    SW_INTR_SOC2SW_INTR3                                                   ,
    SW_INTR_SOC2SW_INTR4                                                   ,
    SW_INTR_SOC2SW_INTR5                                                   ,
    SW_INTR_SOC2SW_INTR6                                                   ,
    SW_INTR_SOC2SW_INTR7                                                   ,
    SW_INTR_SOC2SW_INTR8                                                   ,
    SW_INTR_SOC2SW_INTR9                                                   ,
    SW_INTR_SOC2SW_INTR10                                                  ,
    SW_INTR_SOC2SW_INTR11                                                  ,
    SW_INTR_SOC2SW_INTR12                                                  ,
    SW_INTR_SOC2SW_INTR13                                                  ,
    SW_INTR_SOC2SW_INTR14                                                  ,
    SW_INTR_SOC2SW_INTR15                                                  ,
    SW_INTR_RT2SW_INTR0                                                    ,
    SW_INTR_RT2SW_INTR1                                                    ,
    SW_INTR_RT2SW_INTR2                                                    ,
    SW_INTR_RT2SW_INTR3                                                    ,
    SW_INTR_RT2SW_INTR4                                                    ,
    SW_INTR_RT2SW_INTR5                                                    ,
    SW_INTR_RT2SW_INTR6                                                    ,
    SW_INTR_RT2SW_INTR7                                                    ,
    SW_INTR_RT2SW_INTR8                                                    ,
    SW_INTR_RT2SW_INTR9                                                    ,
    SW_INTR_RT2SW_INTR10                                                   ,
    SW_INTR_RT2SW_INTR11                                                   ,
    SW_INTR_RT2SW_INTR12                                                   ,
    SW_INTR_RT2SW_INTR13                                                   ,
    SW_INTR_RT2SW_INTR14                                                   ,
    SW_INTR_RT2SW_INTR15                                                   ,
    SW_INTR_SAFETY2SW_INTR0                                                , 
    SW_INTR_SAFETY2SW_INTR1                                                ,
    SW_INTR_SAFETY2SW_INTR2                                                ,
    SW_INTR_SAFETY2SW_INTR3                                                ,
    SW_INTR_SAFETY2SW_INTR4                                                ,
    SW_INTR_SAFETY2SW_INTR5                                                ,
    SW_INTR_SAFETY2SW_INTR6                                                ,
    SW_INTR_SAFETY2SW_INTR7                                                ,
    SW_INTR_SAFETY2SW_INTR8                                                ,
    SW_INTR_SAFETY2SW_INTR9                                                ,
    SW_INTR_SAFETY2SW_INTR10                                               ,
    SW_INTR_SAFETY2SW_INTR11                                               ,
    SW_INTR_SAFETY2SW_INTR12                                               ,
    SW_INTR_SAFETY2SW_INTR13                                               ,
    SW_INTR_SAFETY2SW_INTR14                                               ,
    SW_INTR_SAFETY2SW_INTR15                                               ,
}IRQn_Types;



typedef void (*F_isrFn)(unsigned int para);

typedef struct isr_struct{
    F_isrFn isrFn;
    unsigned int para;        
    unsigned int attr;        
    unsigned int isrName;
    const char *description;
}T_isr_list;

#define IRQ_SWITCH_TOTAL_CNT      1020
#define FIQ_SWITCH_TOTAL_CNT      1020
#define ISR_NUM_INVALID           1020

/*which cpu*/
#define ISR_ATTR_SECURE           0x1
#define ISR_ATTR_SAFETY           0x2
#define ISR_ATTR_REALTM           0x4
#define ISR_ATTR_SWITCH           0x8
#define ISR_ATTR_SOCR5            0x10

/*which core*/
#define ISR_ATTR_CORE0         (0<<31)
#define ISR_ATTR_CORE1         (1<<31)
#define ISR_ATTR_CORE_BIT_MASK (1<<31)

/*level or edge( bit 16)*/
#define ISR_ATTR_LEVEL            0X00000
#define ISR_ATTR_EDGE             0X20000
#define IS_EDGE(a)                ((a & 0x30000)>>16)

#define IRQ_DEFINE(__isrName,__isrFn, __para,  __description,__attr)       \
    __attribute__ ((section(".section_irq_table")))        \
    struct isr_struct _section_item_##__isrName##_isr = {  \
        .isrFn = __isrFn,                                \
        .para = __para,                                \
        .attr = __attr,                                 \
        .isrName =  __isrName,               \
        .description =__description,      \
}

#define FIQ_DEFINE(__isrName,__isrFn, __para,  __description,__attr)       \
    __attribute__ ((section(".section_fiq_table")))        \
    struct isr_struct _section_item_##__isrName##_isr = {  \
        .isrFn = __isrFn,                                \
        .para = __para,                                \
        .attr = __attr,                                 \
        .isrName =  __isrName,               \
        .description =__description,      \
}


#endif
